<!DOCTYPE html>
<html>
<head>
    <title>添加新书</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
            padding: 20px 0;
        }
        .form-container {
            background-color: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
            border: 1px solid #e9ecef;
        }
        .form-label {
            color: #2c3e50;
            font-weight: 500;
            margin-bottom: 8px;
        }
        .error-text {
            color: #dc3545;
            font-size: 14px;
            margin-top: 5px;
            padding: 5px 0;
        }
        .form-control {
            border: 1px solid #dee2e6;
            padding: 10px;
        }
        .form-control:focus {
            border-color: #80bdff;
            box-shadow: 0 0 0 0.2rem rgba(0,123,255,.15);
        }
        .page-header {
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 1px solid #dee2e6;
        }
        .btn-group {
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="form-container">
                    <div class="page-header">
                        <h1 class="text-center">添加新书</h1>
                    </div>
                    
                    <form method="post">
                        {% csrf_token %}
                        {% for field in form %}
                            <div class="mb-3">
                                <label class="form-label">{{ field.label }}</label>
                                {% if field.errors %}
                                    <div class="error-text">{{ field.errors }}</div>
                                {% endif %}
                                <input type="{{ field.field.widget.input_type }}" 
                                       name="{{ field.name }}" 
                                       class="form-control" 
                                       id="{{ field.id_for_label }}"
                                       value="{{ field.value|default:'' }}"
                                       {% if field.field.required %}required{% endif %}>
                                {% if field.help_text %}
                                    <small class="form-text text-muted">{{ field.help_text }}</small>
                                {% endif %}
                            </div>
                        {% endfor %}
                        
                        <div class="d-grid gap-2 btn-group">
                            <button type="submit" class="btn btn-primary py-2">添加图书</button>
                            <a href="{% url 'book_list' %}" class="btn btn-outline-secondary">返回列表</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
